/**
 * Description:
 * Class Name:LoggerI18N
 * Date:2022/2/23 14:27
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第7章_Java基础类库._7_7_Java11改进的国际化与格式化._7_7_6_Java9新增的日志API;

import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LoggerI18N {
    public static void main(String[] args) throws Exception{
        // 加载国际化资源包
        var rp = ResourceBundle.getBundle("logMess", Locale.getDefault(Locale.Category.FORMAT));
        // 获取System.Logger对象
        var logger = System.getLogger("fkjava", rp);
        // 设置系统日志级别
        Logger.getLogger("fkjava").setLevel(Level.FINE);
        // 设置使用a.xml保存日志记录
        Logger.getLogger("fkjava").addHandler(new FileHandler("a.xml"));

        logger.log(System.Logger.Level.DEBUG, "debug");
        logger.log(System.Logger.Level.INFO, "info");
        logger.log(System.Logger.Level.ERROR, "error");
    }
}
